package com.mercycrazy.recruit.controller;

import com.mercycrazy.recruit.service.IUserAuthService;
import com.mercycrazy.recruit.user.AdminLoginInfo;
import com.mercycrazy.recruit.user.UsernameAndPassword;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 对 Admin 运营端暴露的鉴权微服务的相关接口
 *
 * @author <a href="mailto:1443424326@qq.com">mercycrazy</a>
 * @since 2023-01-17
 */
@RestController
@RequestMapping("/passport/admin")
@Slf4j
@Tag(name = "Admin运营端鉴权")
public class AdminPassportController {

    private final IUserAuthService userAuthService;

    public AdminPassportController(IUserAuthService userAuthService) {
        this.userAuthService = userAuthService;
    }

    @Operation(summary = "Admin运营端登录",
            description = "Admin运营端登录, 用户名密码登录, 不需要鉴权", method = "POST")
    @PostMapping("/login")
    public AdminLoginInfo login(
            @RequestBody @Valid UsernameAndPassword usernameAndPassword) {
        return userAuthService.adminLogin(usernameAndPassword);
    }
}
